import type { RouteMeta, RouteRecordRaw } from 'vue-router'

export function buildMeta(data: RouteMeta = {}): RouteMeta {
  return {
    ...data,
    module: 'CERT',
  }
}
export default {
  path: '/',
  meta: buildMeta(),
  component: () => import('@/components/layout/DefaultLayout.vue'),
  children: [
    {
      path: '/cert',
      meta: buildMeta({ title: '证书管理' }),
      children: [
        {
          path: 'cert-management/:module?',
          name: 'CertManagement',
          component: () => import('@/views/cert/cert-management'),
          meta: buildMeta({
            title: '证书管理',
            tabs: [
              { title: '证书列表', key: 'list' },
              { title: '申请记录', key: 'record' },
            ],
          }),
        },
        {
          path: 'detail/:id',
          name: 'CertDetail',
          component: () => import('@/views/cert/cert-management/cert-detail'),
          meta: buildMeta({
            title: '管理',
            breadcrumbs: [
              {
                title: '证书管理',
                to: { name: 'CertManagement' },
              },
            ],
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'CertManagement',
          }),
        },
        {
          path: 'cert-account',
          name: 'CertAccount',
          component: () => import('@/views/cert/cert-account'),
          meta: {
            title: 'ACME 账户',
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'CertAccount',
          },
        },
        {
          path: 'cert-domain',
          name: 'CertDomain',
          component: () => import('@/views/cert/cert-domain'),
          meta: {
            title: '域名管理',
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'CertDomain',
          },
        },
      ],
    },
  ],
} satisfies RouteRecordRaw
